package com.ubing.boot.notesforjava.mq;

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.ubing.boot.notesforjava.domel.entity.UserInfo;
import com.ubing.boot.notesforjava.domel.entity.UserSensitive;
import com.ubing.boot.notesforjava.domel.entity.UserTest;
import com.ubing.boot.notesforjava.utils.ConvertUtils;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
@RocketMQMessageListener(consumerGroup = "TopicTest",topic = "TopicTest")
public class RocketMQConsumerListener implements RocketMQListener<String> {
    @Override
    public void onMessage(String s) {
//        List objects = JSON.parseArray(s, UserTest.class);
//        List<UserSensitive> convert = ConvertUtils.convert(objects, UserSensitive.class);
//        System.out.println(convert);

//        List<JSONObject> jsonObjects = JSON.parseArray(s, JSONObject.class);
//        List<UserSensitive> userInfos = ConvertUtils.jsonConvert(jsonObjects, UserSensitive.class);
        System.out.println(s);

    }

//    @Override
//    public void onMessage(UserInfo userInfo) {
//        System.out.println("消费消息："+userInfo.getUserId());
//    }
}
